<template>
	<view>
		<view class="hm-p-20">
			<view class="card">
				<image class="bg" :src="userInfo.v.grade.vip[lv].card_cover"></image>
				<view class="mask">
					<image :src="userInfo.avatar.url"></image>
					<view class="text">
						会员卡
						<view class="lv">
							{{userInfo.v.grade.vip[lv].name}}
						</view>
					</view>
					<view class="id">
						NO.{{100000000+userInfo.user_id}}
					</view>
				</view>
			</view>
			<view class="account">
				<u-grid :border="false" col="3">
					<u-grid-item  @click="goTo('user/wallet/index')">
						<view class="number">{{userInfo.money}}</view>
						<view class="text">余额</view>
					</u-grid-item>
					<u-grid-item>
						<view class="number">{{userInfo.usable}}</view>
						<view class="text">积分</view>
					</u-grid-item>
					<u-grid-item>
						<view class="number">{{userInfo.score}}</view>
						<view class="text">成长值</view>
					</u-grid-item>
				</u-grid>
			</view>
			<view class="menu">
				<view class="navbar-list" @click="goTo('user/wallet/index')">
					<image :src="applet.domain + '/addons/pt/user/payment.png'"></image>
					在线充值
					<view class="arrow-right">
						<u-icon color="#c0c4cc" name="arrow-right"></u-icon>
					</view>
				</view>
				<view class="navbar-list" @click="goTo('user/vip/open?action=equity')">
					<image :src="applet.domain + '/addons/pt/user/equity.png'"></image>
					会员权益
					<view class="arrow-right">
						<u-icon color="#c0c4cc" name="arrow-right"></u-icon>
					</view>
				</view>
				<view class="navbar-list" @click="describe = true">
					<image :src="applet.domain + '/addons/pt/user/about.png'"></image>
					会员声明
					<view class="arrow-right">
						<u-icon color="#c0c4cc" name="arrow-right"></u-icon>
					</view>
				</view>
			</view>
		</view>
		<!-- 会员声明信息框 --> 
		<u-popup :show="describe" @close="describe = false" mode="center" round="8" :closeable="true">
			<view class="hm-popup">
				<view class="hm-p-b-20 hm-border-b">会员声明</view>
				<view class="hm-p-20">
					会员开通后即可活得积分与成长值，积分与成长值同步获取，每消费1元即可同时活得1个积分和一个成长值。
				</view>
			</view>
		</u-popup>
		<!-- 技术支持 -->
		<view class="hm">
			{{applet.copyright}} <text class="v">V{{applet.version}}</text>
		</view>
	</view>
</template>

<script>
	const App = getApp();

	export default {
		data() {
			return {
				userInfo: {},
				applet: {},
				lv: 0,//当前会员等级 0-5
				describe:false,//是否显示会员声明显示框
			};
		},
		props: {},

		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad(options) {
			let _this = this;
			_this.applet = uni.getStorageSync('applet');
		},

		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow() {
			let _this = this;
			_this.getUserDetail();
		},

		methods: {
			/**
			 * 获取当前用户信息
			 */
			getUserDetail() {
				let _this = this;
				App._get('user/detail', {}, result => {
					_this.userInfo = result.data;
					_this.lv = result.data.v.value-1;
				});
			},
			/**
			 * 菜单列表导航跳转
			 */
			goTo(url) {
				App.goTo(url); // 转跳指定的页面
			},
		}
	};
</script>
<style lang="scss" scoped>
	.card{
		width: 710rpx;
		height: 328rpx;
		z-index: 1;
		position:relative;
		.bg{
			width: 100%;
			height: 100%;
			border-radius: 20rpx;
		}
		.mask{
			border-radius: 20rpx;
			z-index: 100;
			position: absolute;
			top: 0rpx;
			left: 0rpx;
			width: 100%;
			height: 100%;
			background: rgba(0, 0, 0, 0.3);
			color: #fff;
			image{
				border-radius: 50%;
				width: 80rpx;
				height: 80rpx;
				float: left;
				margin: 50rpx 20rpx 0rpx 50rpx;
			}
			.text{
				padding-top: 50rpx;
				font-weight: bold;
				font-size: 30rpx;
				.lv{
					font-size: 24rpx;
					padding-top: 10rpx;
					font-weight: normal;
				}
			}
			.id{
				padding: 150rpx 50rpx 0rpx 0rpx;
				text-align: right;
				font-size: 28rpx;
			}
		}
	}
	.account{
		margin-top: 20rpx;
		padding: 20rpx;
		border-radius: 8rpx;
		background-color: #fff;
		text-align: center;
		color: #303133;
		font-weight: bold;
		.text{
			padding-top: 10rpx;
			font-size: 30rpx;
		}
	}
	.menu {
		margin-top: 20rpx;
		border-radius: 8rpx;
		padding: 0 20rpx 30rpx 20rpx;
		background-color: #fff;
	
		.navbar-list {
			padding-top: 30rpx;
			line-height: 50rpx;
			image {
				float: left;
				margin-right: 20rpx;
				height: 50rpx;
				width: 50rpx;
			}
			.text{
				display: inline-block;
				float: right;
				margin-right: 10rpx;
				font-size: 24rpx;
				color: #fa3534;
			}
			.arrow-right {
				display: inline-block;
				float: right;
				margin-top: 10rpx;
			}
		}
	}
</style>
